home *** CD-ROM | disk | FTP | other *** search
-
- /*
- RexxDoesHTML2AmigaGuide V0.9 written at 14 Apr 1996 by Michael Ranner
- This piece of code is Public Domain. Use it, distribute it, modify it!
- */
-
- arg src opt
-
- if index(opt, '?') ~= 0 then do
- say 'Source/A'
- exit
- end
-
- open('HTML', src, 'R')
- name = left(src, lastpos('.', src)) || 'guide'
- open('Guide', name,'W')
-
- writeln('Guide', '@DATABASE ' || src)
- writeln('Guide', '@REMARK Converted by RexxDoesHTML2AmigaGuide V1.0 by Michael Ranner')
- writeln('Guide', '@NODE Main')
- writeln('Guide', '@WORDWRAP')
-
- spaces = 0;
- pushes = 0;
-
- do until eof('HTML') = 1
- srcline = readln('HTML')
- dstline = ''
-
- do while srcline ~= ''
-
- parse var srcline start '<' token arg'>' srcline
- token = compress(upper(token))
-
- select
-
- when token = '/TITLE' then nop
-
- when token = 'P' then dstline = dstline || start || '0A0A'X
-
- when token = 'H1' | token = 'H2' then dstline = '0A0A'X || dstline || start
-
- when token = '/H1' | token = '/H2' then dstline = dstline || start || '0A0A'X
-
- when token = 'H3' | token = 'H5' then dstline = '0A'X || '@{i}' || dstline || start
-
- when token = '/H3' | token = '/H5' then dstline = dstline || start || '@{ui}' || '0A'X
-
- when token = 'H4' | token = 'H6' then dstline = '0A'X || dstline || start
-
- when token = '/H4' | token = '/H6' then dstline = dstline || start || '0A'X
-
- when token = 'LI' then dstline = dstline || start || '0A'X || '* '
-
- when token = 'UL' then do
- spaces = spaces + 6
- dstline = dstline || start || '0A'X || '@{LINDENT ' || spaces || '}' || '0A'X
- end
-
- when token = '/UL' then do
- spaces = spaces - 6
- dstline = dstline || start || '0A'X || '@{LINDENT ' || spaces || '}' || '0A'X
- end
-
- when token = 'I' then dstline = dstline || start || '@{I}'
- when token = '/I' then dstline = dstline || start || '@{UI}'
- when token = 'B' then dstline = dstline || start || '@{B}'
- when token = '/B' then dstline = dstline || start || '@{UB}'
-
- when token = 'A' then do
- parse var arg token '=' node
- token = compress(upper(token))
- node = compress(node, '"')
-
- if (token = 'HREF') & (node ~='') then do
- prot = upper(left(node, pos(':', node)))
-
- say prot
-
- select
-
- when prot = 'HTTP:' then do
- node = pushNode(node)
- end
-
- when prot = 'GOPHER:' then do
- node = pushNode(node)
- end
-
- when prot = 'FTP:' then do
- node = pushNode(node)
- end
-
- when prot = 'WAIS:' then do
- node = pushNode(node)
- end
-
- when prot = 'NEWS:' then do
- node = pushNode(node)
- end
-
- when prot = 'MAILTO:' then do
- node = pushNode(node)
- end
-
- when prot = 'LOCALHOST:' then do
- node = left(node, lastpos('.', node)) || 'guide/MAIN'
- node = delstr(node, 1, lastpos('://', node) + 2)
- end
-
- otherwise node = left(node, lastpos('.', node)) || 'guide/MAIN'
-
- end
-
- dstline = dstline || start || '@{"'
- end
- end
-
- when token = '/A' then dstline = dstline || start || '" LINK ' || node || '}'
-
- when token = 'IMG' then do
- parse var arg token '=' name token2 '=' alttext
- alttext = compress(alttext, '"')
-
- if alttext ~= '' then dstline = dstline || start || '[' || alttext || ']'
- else dstline = dstline || start || '[Image]'
- end
-
- otherwise dstline = dstline || start
- end
- end
-
- writech('Guide', dstline)
-
- end
-
- writeln('Guide', '0A0A'X || 'Converted at ' || date() || ' with RexxDoesHTML2AmigaGuide by Michael Ranner.' || '0A0A'X)
- writeln('Guide', '@ENDNODE')
-
- do while pushes ~= 0
- parse pull node
- writeln('Guide', '@NODE ' || translate(node, '__', ':/') || '0A0A'X || node || '0A0A'X || @ENDNODE)
- pushes = pushes - 1
- end
-
- close('Guide')
- close('HTML')
-
- exit
-
- pushNode: procedure expose pushes
- parse arg node
- push node
- pushes = pushes + 1
- node = translate(node, '__', ':/')
- return node
-